package counter.com.baomidou.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import counter.com.baomidou.entity.Iphopinfo;
import counter.com.baomidou.service.IIphopinfoService;
import counter.com.common.Result;
import counter.com.connproperty.counter.IphopinfoSearchProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2020-11-08
 */
@RestController
@RequestMapping("/iphopinfo")
public class IphopinfoController {
    @Autowired
    IIphopinfoService service;

    @PostMapping("/search")
    public Result search(@RequestBody IphopinfoSearchProperty data) {
        LambdaQueryWrapper<Iphopinfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.orderByDesc(true, Iphopinfo::getId).eq(Iphopinfo::getHops, data.getHop());
        Page<Iphopinfo> page = new Page<>(data.getPage(), data.getPagesize());
        IPage<Iphopinfo> iPage = service.page(page, wrapper);
        return Result.success(iPage);
    }
}

